package com.chushouya.manager.constants;


import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Strings;

import java.util.Objects;

public enum TradeStatusEnum implements IEnum<Integer> {
    FAIL(-1, "交易失败"),
    TRADING(0, "交易中"),
    SUCCESS(1, "交易成功");
    private final Integer value;

    private final String desc;

    TradeStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String getDesc(Integer status) {
        for (TradeStatusEnum thisEnum : TradeStatusEnum.values()) {
            if (Objects.equals(thisEnum.value, status)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }
}
